<?php
// +----------------------------------------------------------------------
//            -------------------------
//           /   / ----------------\  \
//          /   /             \  \
//         /   /              /  /
//        /   /    /-------------- /  /
//       /   /    /-------------------\  \
//      /   /                   \  \
//     /   /                     \  \
//    /   /                      /  /
//   /   /      /----------------------- /  /
//  /-----/      /---------------------------/
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://baimifan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Sage 2016/7/22  8:54
// +----------------------------------------------------------------------
namespace Admin\Controller;
use Service\ServiceContainer;

class SettingController extends BaseController{
    function __construct() {
        parent::__construct();
        $this->di=new ServiceContainer();
    }

    function index(){
        $this->display();
    }

    function saveRent(){
        $rentmax_md=I('post.rentmax_md');
        $rentmax_wx=I('post.rentmax_wx');
        $r1=M('Setting')->where(['name'=>'rentmax_md'])->data(['value'=>$rentmax_md])->save();
        $r2=M('Setting')->where(['name'=>'rentmax_wx'])->data(['value'=>$rentmax_wx])->save();
        $j=[
            'status'=>'success',
        ];
        if(!$r1 && !$r2){
            $j['data']='修改成功,未作任何修改';
        }else{
            $j['data']='修改成功';
        }
        echo json_encode($j,JSON_UNESCAPED_UNICODE);
    }

    function saveName(){
        $act_freenum_name=I('post.act_freenum_name');
        $rent_freenum_name=I('post.rent_freenum_name');
        $r1=M('Setting')->where(['name'=>'act_freenum_name'])->data(['value'=>$act_freenum_name])->save();
        $r2=M('Setting')->where(['name'=>'rent_freenum_name'])->data(['value'=>$rent_freenum_name])->save();
        $j=[
            'status'=>'success',
        ];
        if(!$r1 && !$r2){
            $j['data']='修改成功,未作任何修改';
        }else{
            $j['data']='修改成功';
        }
        echo json_encode($j,JSON_UNESCAPED_UNICODE);
    }
}